package com.ranqianhui.ojbackendjudgeservice.codesandbox;

import com.ranqianhui.ojbackendjudgeservice.codesandbox.impl.ExampleCodeSanbox;
import com.ranqianhui.ojbackendjudgeservice.codesandbox.impl.RemoteCodeSanbox;
import com.ranqianhui.ojbackendjudgeservice.codesandbox.impl.ThirdPartyCodeSanbox;

/**
 * 代码沙箱工厂（根据字符串参数创建指定的代码沙箱实例）
 */
public class CodeSandboxFactory {

    /**
     * 创建代码沙箱示例
     * @param type 沙箱类型
     * @return
     */
    public static CodeSandbox newInstance(String type){
      switch (type){
          case "example":
              return new ExampleCodeSanbox();
          case "remote":
              return new RemoteCodeSanbox();
          case "thirdParty":
              return new ThirdPartyCodeSanbox();
          default:
              return new ExampleCodeSanbox();

      }

    }

}
